<script setup>
import Banner from './components/Banner.vue'
import HitMovie from './components/HitMovie.vue'
import MovieLists from '@/components/MovieLists.vue'
import Leaderboard from './components/Leaderboard.vue'

import { findCategoryListAPI } from '@/apis/home.js'
import { ref } from 'vue'


const movieCategory="1-1"
const televisionCategory="1-2"

const movieList = ref([])
const televisioList = ref([])
const getCategoryList = async (category,list) => {
  const res = await findCategoryListAPI(category)
  list.value = res
  console.log(res);
  
}


getCategoryList(movieCategory,movieList)
getCategoryList(televisionCategory,televisioList)


</script>


<template>
    <Banner></Banner>
    <HitMovie></HitMovie>
    <MovieLists title="电影">
        <ul class="movie_list">
            <li v-for="item in movieList" :key="item.id">

                <RouterLink active-class="active" :to="`/detail/${item.id}`">
                    <div class="movie_head" :style="{backgroundImage: 'url('+item.pic+')'}">
                        <span class="movie_test_left">{{ item.num == 0 ? "完结" :"更新至"+item.num+"集"  }}</span><span class="movie_test_right">{{item.star}}</span>
                    </div>
                    <div class="movie_info">
                        <p>{{item.title}}</p>
                        <span class="view-text">{{item.des}}</span>
                    </div>
                </RouterLink>
            </li>

            <!-- 主体内容区域 -->
        </ul>
    </MovieLists>
    <MovieLists title="电视">
        <ul class="movie_list">
            <li v-for="item in televisioList" :key="item.id">
                <RouterLink active-class="active" :to="`/detail/${item.id}`">
                    <div class="movie_head" :style="{backgroundImage: 'url('+item.pic+')'}">
                        <span class="movie_test_left">{{ item.num == 0 ? "完结" :"更新至"+item.num+"集"  }}</span><span class="movie_test_right">{{item.star}}</span>
                    </div>
                    <div class="movie_info">
                        <p>{{item.title}}</p>
                        <span class="view-text">{{item.des}}</span>
                    </div>
                </RouterLink>
            </li>

            <!-- 主体内容区域 -->
        </ul>
    </MovieLists>
    <Leaderboard></Leaderboard>
</template>



<style scoped lang='scss'>
.container {


    .rebboIcon {
        font-size: 24px;
        color: #ff5f00;
    }

    .line {
        margin-left: 10px;
        margin-right: 10px;
    }


    // 设置文本超出使用省略号
    .view-text {
        display: inline-block;
        white-space: nowrap;
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }


    background: #fff;

    .pannel {
        display: flex;
        justify-content: space-between;

        .pannel_head {
            width: 400px;

            h2 {
                display: inline-block;

            }

            .more {
                padding-left: 15px;
            }



        }

        .right_menu {

            li {
                line-height: 70px;
                float: left;

                em {
                    color: #ff5f00;
                }
            }

        }

        a:hover {
            color: $xtxColor;
        }


    }

    .movie_list {
        display: flex;
        height: 850px;
        justify-content: space-between;
        flex-flow: row wrap;

        li {
            width: 19%;
            height: 50%;

            .movie_head {
                width: 100%;
                height: 70%;
                background-size: cover;
                background-position: center;
                
                position: relative;
                font-size: 15px;
                font-weight: bold;

                .movie_test_left {
                    letter-spacing:2px;
                    color: #ff5f00;
                    position: absolute;
                    bottom: 8px;
                    padding-left: 5px
                }

                .movie_test_right {
                    letter-spacing:2px;
                    color: #ff5f00;
                    position: absolute;
                    bottom: 8px;
                    right: 8px;
                }
            }

            .movie_info {
                margin-top: 5px;

                p {
                    font-size: 18px;
                    font-weight: bold;
                }

                span {
                    font-size: 14px;
                    color: #666;
                }

            }
        }
    }
}
</style>